package com.ruoyi.web.controller.material.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.controller.material.entity.ylWarehouse;
import org.apache.ibatis.annotations.Mapper;

/**
 * 仓库管理Mapper接口
 *
 * @author jzx
 * @date 2025-10-22
 */
@Mapper
public interface WarehouseMapper extends BaseMapper<ylWarehouse> {
    /**
     * 判断仓库名称是否存在
     *
     * @param warehouseName
     * @return
     */
    default boolean getWarehouseName(String warehouseName, String id) {
        if (StringUtils.isNotEmpty(id)) {
            return selectCount(new LambdaQueryWrapper<ylWarehouse>().eq(ylWarehouse::getWarehouseName, warehouseName).ne(ylWarehouse::getId, id)) > 0;
        }
        return selectCount(new LambdaQueryWrapper<ylWarehouse>().eq(ylWarehouse::getWarehouseName, warehouseName)) > 0;
    }

    ;
}
